# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/7 22:15
# @Author   : Robot-Zsj
"""
description:

input
9 4
output
1 2 3
* * 4
9 * 5
8 7 6
"""
import math

n, m = map(int, input().split())


def getResult():
    k = math.ceil(n / m)

    matrix = [['*'] * k for _ in range(m)]

    step = 1
    x = 0
    y = 0

    while step <= n:
        while y < k and matrix[x][y] == '*' and step <= n:
            matrix[x][y] = str(step)
            step += 1
            y += 1
        y -= 1
        x += 1

        while x < m and matrix[x][y] == '*' and step <= n:
            matrix[x][y] = str(step)
            step += 1
            x += 1
        x -= 1
        y -= 1

        while y >= 0 and matrix[x][y] == '*' and step <= n:
            matrix[x][y] = str(step)
            step += 1
            y -= 1
        y += 1
        x -= 1

        while x >= 0 and matrix[x][y] == '*' and step <= n:
            matrix[x][y] = str(step)
            step += 1
            x -= 1
        x += 1
        y += 1

    for i in matrix:
        print(" ".join(i))


getResult()
